package model;
import java.util.Observable;
import java.util.Observer;

/**
 * Team EBE
 * 
 * RelationshipEditor.java is an intermediary with functionality to edit a given relationship so that 
 * views do not have to directly access the relationship itself; Used primarily by the 
 * relationship editor GUI; Currently it implements observer although we are not fully 
 * implementing the functionality yet
 *
 */
public class RelationshipEditor implements Observer{
	private RelationshipImpl relationshipToEdit;
	public RelationshipEditor(){
		
	}
	
	public void update(Observable obj, Object arg){
		if (arg instanceof RelationshipImpl){
			this.relationshipToEdit = (RelationshipImpl) arg;
		}
		if (arg instanceof ClassImpl){
			this.relationshipToEdit = null;
		}
	}
	
	public void commitChanges (int srcMinIn, int srcMaxIn, int destMinIn, int destMaxIn, AnchorPoint srcIn, AnchorPoint destIn){
		this.relationshipToEdit.setSrcMin(srcMinIn);
		this.relationshipToEdit.setSrcMax(srcMaxIn);
		this.relationshipToEdit.setDestMin(destMinIn);
		this.relationshipToEdit.setDestMax(destMaxIn);
		this.relationshipToEdit.setSrc(srcIn);
		this.relationshipToEdit.setDest(destIn);
	}
	
	public int getSrcMin( ){
		return this.relationshipToEdit.getSrcMin();
	}
	
	public int getSrcMax( ){
		return this.relationshipToEdit.getSrcMax();
	}
	
	public int getDestMax( ){
		return this.relationshipToEdit.getDestMax();
	}
	
	public int getdestMin( ){
		return this.relationshipToEdit.getDestMin( );
	}
	
	public String getSrcName( ){
		return this.relationshipToEdit.getSrc().getName();
	}
	
	public String getDestName( ){
		return this.relationshipToEdit.getDest().getName( );
	}

}
